package com.ytg.apt;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

/**
 * 作者： 于堂刚,
 * 日期： 2021/6/14.
 * 描述：
 */
public class MView extends LinearLayout {
    public MView(Context context) {
        super(context);
        init(context);
    }
void init(Context context){
    setOrientation(VERTICAL);
    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.item, null);
    layout.setLayoutParams(new LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    tv = layout.findViewById(R.id.mTvname);
    addView(layout);
}
    public MView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    TextView tv;

    public MView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);

    }

    public void setText(String text) {
        tv.setText(text);
    }
    public String getText(){
        return tv.getText().toString();
    }

    public void setContent(String text) {
        tv.setText(text);
    }
    public String getContent(){
        return tv.getText().toString();
    }
}
